<?php

/**
* 切换国家
*/
class openapi_api_function_v1_country extends openapi_api_function_abstract implements openapi_api_function_interface{

	public function getlist($params,&$code,&$sub_msg)
	{
		$list = app::get('cellphone')->model('country')->getList("*",array(),0,-1,"porder asc");
		foreach ($list as $key => &$ll) {
			$ll['flag_url'] = $this->get_img_url($ll['flag_id']);
		}
		return $this->apiData(true,$list,200);
	}

	public function get_img_url($image_id,$size){
        $url = cellphone_image_storager::image_path($image_id,$size);
        if(empty($url)){
            $imageDefault = app::get('cellphone')->getConf('image.set');
            $url = cellphone_image_storager::image_path($imageDefault[strtoupper($size)]['default_image']);
        }
        return $url;
    }

}